/* 
 *  Syntelos XB
 *  Copyright (C) 2006 John Pritchard.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307 USA
 */

package syntelos.xb.at;

/** 
 * 
 * 
 * @author jdp
 */
public final class InnerClasses 
    extends syntelos.xb.Attribute
{
    public final static java.lang.String ATNAME = "InnerClasses";
    public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:inner-classes");

    public final static class Info
        extends syntelos.xb.Base
    {
        public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:inner-classes.info");


        public final static class InnerClass
            extends syntelos.xb.Type.Class
        {
            public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:inner-classes.info.inner-class");

            public InnerClass(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
                super(doc,name);
            }
            public InnerClass(org.w3c.dom.Document doc){
                this(doc,NAME);
            }
            public InnerClass(){
                this(DOC_NIL);
            }
        }

        public final static class OuterClass
            extends syntelos.xb.Type.Class
        {
            public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:inner-classes.info.outer-class");

            public OuterClass(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
                super(doc,name);
            }
            public OuterClass(org.w3c.dom.Document doc){
                this(doc,NAME);
            }
            public OuterClass(){
                this(DOC_NIL);
            }
        }

        public final static class InnerName
            extends syntelos.xb.Name
        {
            public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:inner-classes.info.inner-name");

            public InnerName(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
                super(doc,name);
            }
            public InnerName(org.w3c.dom.Document doc){
                this(doc,NAME);
            }
            public InnerName(){
                this(DOC_NIL);
            }
        }

        public final static class InnerAccess
            extends syntelos.xb.Access
        {
            public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:inner-classes.info.inner-access");

            public InnerAccess(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
                super(doc,name);
            }
            public InnerAccess(org.w3c.dom.Document doc){
                this(doc,NAME);
            }
            public InnerAccess(){
                this(DOC_NIL);
            }
        }


        public Info(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
            super(doc,name);
        }
        public Info(org.w3c.dom.Document doc){
            this(doc,NAME);
        }
        public Info(){
            this(DOC_NIL);
        }

        public InnerClass getInnerClass(){
            InnerClass field = (InnerClass)this.getChildByName("inner-classes.info.inner-class");
            if (null == field){
                field = new InnerClass();
                this.appendChild(field);
            }
            return field;
        }
        public OuterClass getOuterClass(){
            OuterClass field = (OuterClass)this.getChildByName("inner-classes.info.outer-class");
            if (null == field){
                field = new OuterClass();
                this.appendChild(field);
            }
            return field;
        }
        public InnerName getInnerName(){
            InnerName field = (InnerName)this.getChildByName("inner-classes.info.inner-name");
            if (null == field){
                field = new InnerName();
                this.appendChild(field);
            }
            return field;
        }
        public InnerAccess getInnerAccess(){
            InnerAccess field = (InnerAccess)this.getChildByName("inner-classes.info.inner-access");
            if (null == field){
                field = new InnerAccess();
                this.appendChild(field);
            }
            return field;
        }
        public void readCF(syntelos.xb.IO.Uri src, syntelos.xb.CF.Reader reader)
            throws java.io.IOException
        {
            this.getInnerClass().readCF(src,reader);
            this.getOuterClass().readCF(src,reader);
            this.getInnerName().readCF(src,reader);
            this.getInnerAccess().readCF(src,reader);
        }
        public void writeCF(syntelos.xb.IO.Uri dst, syntelos.xb.CF.Writer writer)
            throws java.io.IOException
        {
            this.getInnerClass().writeCF(dst,writer);
            this.getOuterClass().writeCF(dst,writer);
            this.getInnerName().writeCF(dst,writer);
            this.getInnerAccess().writeCF(dst,writer);
        }
    }

    public InnerClasses(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
        super(doc,name);
    }
    public InnerClasses(org.w3c.dom.Document doc){
        this(doc,NAME);
    }
    public InnerClasses(){
        this(DOC_NIL);
    }

    public syntelos.iou.dom.Node compile(){

        this.getAttributeName().setNodeValue("utf8:InnerClasses");

        return super.compile();
    }
    public int atlen(){
        int count = this.countChildNodes();
        return (2 + (8 * count));
    }
    public void readCF(syntelos.xb.IO.Uri src, syntelos.xb.CF.Reader reader)
        throws java.io.IOException
    {
        int at_len = reader.readInt();
        int count = reader.readUnsignedShort();
        Info info;
        for (int cc = 0; cc < count; cc++){
            info = new Info();
            this.appendChild(info);
            info.readCF(src,reader);
        }
    }
    public void writeCF(syntelos.xb.IO.Uri dst, syntelos.xb.CF.Writer writer)
        throws java.io.IOException
    {
        this.getAttributeName().writeCF(dst,writer);
        int at_len = this.atlen();
        writer.writeInt(at_len);
        int count = this.countChildNodes();
        writer.writeShort(count);
        if (0 < count){
            org.w3c.dom.NodeList children = this.getChildNodes();
            Info info;
            for (int cc = 0; cc < count; cc++){
                info = (Info)children.item(cc);
                info.writeCF(dst,writer);
            }
        }
    }
}
